/**
 * 定义冻结表格行列的工具类模块
 */
(function(window, angular, undefined){

	var Module = angular.module('water.common.directive',[]);
	
	/**
	 * 监听dom内容变化，变化完成后触发逻辑
	 */
	Module.directive("contentChanged", function() {
		return {
		    restrict: "A",     
		    scope: {              // 设置指令对于的scope 
		    },
		    controller: [ "$scope", function ($scope) {
		    	
		    }], 
		    link:function($scope, elm, attrs, controller){
		    	var lastTimeStamp = 0;
		    	var handle ;
		    	
		    	$(elm).bind("DOMNodeInserted",function(e){
		    		
		    		if((e.timeStamp - lastTimeStamp) > 1000){
		    			handle = setInterval(waitForComplete,500);
		    		}
		    		lastTimeStamp = e.timeStamp;
		    	})
		    	
		    	function waitForComplete(){
		    		var currentTimeStamp = Date.parse(new Date());
		    		if((currentTimeStamp - lastTimeStamp) > 500 ){
		    			console.log("加载完成！");
		    			clearInterval(handle);
		    		}
		    	}
	        }
		 } 
	});
	
}(window, angular));